﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;
using System.ServiceModel.DomainServices.Server.ApplicationServices;
using System.Web;
using System.ServiceModel.Channels;
using System.ServiceModel;
namespace Biciq.Web.UI.Servicios
{
    [EnableClientAccess]
    public class BiciqAuthenticationService : AuthenticationBase<User>
    {

        protected override bool ValidateUser(string userName, string password)
        {
            var context = OperationContext.Current;
            var prop = context.IncomingMessageProperties;
            var endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
            HttpContext.Current.Session.Add("Usuario", userName);
            HttpContext.Current.Session.Add("Ip", endpoint == null ? string.Empty : endpoint.Address);
            return base.ValidateUser(userName, password);
        }
    }

    public class User : UserBase
    {
        // NOTE: Profile properties can be added here 
        // To enable profiles, edit the appropriate section of web.config file.

        // public string MyProfileProperty { get; set; }
    }
}